<?php
/*! \brief
 * This is the WFOpt class major purpose for setting WidgetFramework Option
 * \author William Su
 */
class WFOpt
{
    private static $instance;
    /**
     * @var WF
     */
    private $objFramework;
    public function __construct($objFramework){
        $this->objFramework = $objFramework;
    }
    public function getWFTableName(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = $this->objFramework->getWidgetPoolFactory()->getWidgetPoolOpt()->getWidgetPoolTableName();
            $ret[] = 'users';
            $ret[] = 'userdata';
            $ret[] = 'serverlist';
            $ret[] = 'serverlisttype';
            $ret[] = 'proxylist';
            $ret[] = 'CONTAINER';
            $ret[] = 'WIDGET_COMPONENT';
            $ret[] = 'WIDGET_COMPONENT_CATEGORY';
            $ret[] = 'WIDGET_COMPONENT_CATEGORY_MAPPING';
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     *\brief Description
     * - Get Option Array of valid file interface
     * @return array
     */
    public function getFileInterface(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = array();
            $ret['initWFDBSchema'] = 'initWFDBSchema.php';
            $ret['upgradeWF'] = 'upgradeWF.php';
            $ret['initWidgetPoolDBSchema'] = 'initWidgetPoolDBSchema.php';
            $ret['synWidgetXMLToDB'] = 'synWidgetXMLToDB.php';
            $ret['synWidgetComponentXMLToDB'] = 'synWidgetComponentXMLToDB.php';
            $ret['synServerListType'] = 'synServerListType.php';
            $ret['execDBUpdateFilter'] = 'execDBUpdateFilter.php';
            $ret['turnOnWidgetOfCategoryByVersion'] = 'turnOnWidgetOfCategoryByVersion.php';
            $ret['turnOffWidgetOfCategoryByVersion'] = 'turnOffWidgetOfCategoryByVersion.php';
            $ret['deleteWidgetFromDBByWidgetName'] = 'deleteWidgetFromDBByWidgetName.php';
            $ret['synWidgetXMLToDBByWidgetName'] = 'synWidgetXMLToDBByWidgetName.php';
            $ret['deleteUserByAccount'] = 'deleteUserByAccount.php';
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     *\brief Description
     * - Get Option Array description of file interface
     * @return array
     */
    public function getFileInterfaceDescription(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = array();
            $ret['initWFDBSchema'] = 'Initial widget framework table schema to Database. Add WP_UPDATE_LOG.log_id=1'; //initWFDBScheme.php
            $ret['upgradeWF'] = 'Upgrade Widget Framework Version from /path/to/widget_old to /path/to/widget'; // upgradeWF.php
            $ret['initWidgetPoolDBSchema'] = 'Initial widget pool table schema to Database.'; //initWidgetPoolDBScheme.php
            $ret['synWidgetXMLToDB'] = 'Traversal widgets folder and synchronous widget.xml to Database.'; //synWidgetXMLToDB.php
            $ret['synWidgetComponentXMLToDB'] = 'Traversal widgetComponent folder and synchronous component.xml to Database.'; //synWidgetXMLToDB.php
            $ret['synServerListType'] = 'ServerListType command line interface'; //synServerListType.php
            $ret['execDBUpdateFilter'] = 'Execute All Filter Rules which save in TableWPUpdateFilter'; //execDBUpdateFilter.php
            $ret['turnOnWidgetOfCategoryByVersion'] = 'Turn On widget of category by version.'; //turnOnWidgetOfCategoryByVersion.php
            $ret['turnOffWidgetOfCategoryByVersion'] = 'Turn Off widget of category by version.'; //turnOffWidgetOfCategoryByVersion.php
            $ret['deleteWidgetFromDBByWidgetName'] = 'Delete widget by widget name.'; //deleteWidgetFromDBByWidgetName.php
            $ret['synWidgetXMLToDBByWidgetName'] = 'Synchronize widget.xml to DB widget name.'; //synWidgetXMLToDBByWidgetName.php
            $ret['deleteUserByAccount'] = 'Delete user by account.'; //deleteUserByAccount.php
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     *\brief Description
     * - Get Option Array file interface which have to save to WP_UPDATE_FILTER
     * @return array
     */
    public function getFileInterfaceHaveToSaveToDB(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = array();
            $ret[] = 'turnOnWidgetOfCategoryByVersion.php';
            $ret[] = 'turnOffWidgetOfCategoryByVersion.php';
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     *\brief Description
     * - Get Option Array file interface which required version number
     * - EX : turnOnWidgetOfCategoryByVersion.php / turnOffWidgetOfCategoryByVersion.php required version number
     * @return array
     */
    public function getFileInterfaceRequiredVersionNumber(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = array();
            $ret[] = 'turnOnWidgetOfCategoryByVersion.php';
            $ret[] = 'turnOffWidgetOfCategoryByVersion.php';
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     *\brief Description
     * - Get Option Array file interface which required filter_target
     * - EX : turnOnWidgetOfCategoryByVersion.php / turnOffWidgetOfCategoryByVersion.php required filter_target(widget CategoryName)
     * @return array
     */
    public function getFileInterfaceRequiredFilterTarget(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = array();
            $ret[] = 'turnOnWidgetOfCategoryByVersion.php';
            $ret[] = 'turnOffWidgetOfCategoryByVersion.php';
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     *\brief Description
     * - Get Option Array file interface which required parameter
     * - EX : turnOnWidgetOfCategoryByVersion.php / turnOffWidgetOfCategoryByVersion.php required parameter(widget CategoryName)
     * - PS : parameter = WP_UPDATE_FILTER.filter_condition
     * @return array
     */
    public function getFileInterfaceRequiredParameter(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = array();
            $ret[] = 'synServerListType.php';
            $ret[] = 'turnOnWidgetOfCategoryByVersion.php';
            $ret[] = 'turnOffWidgetOfCategoryByVersion.php';
            $ret[] = 'deleteUserByAccount.php';
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     *\brief Description
     * - Get Option array of all widget type
     * @return array
     */
    public function getWidgetAllType(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = array();
            $arrWidgetType = $this->getWidgetType();
            $arrConfigureWidgetType = $this->getConfigureWidgetType();
            $ret = array_merge($arrWidgetType, $arrConfigureWidgetType);
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     *\brief Description
     * - Get Option array of common widget type, excerpt configure widget
     * @return array
     */
    public function getWidgetType(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = array();
            $ret[] = '0';
            $ret[] = '1';
            $ret[] = '2';
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    /**
     *\brief Description
     * - Get Option array of configure widget type, excerpt common widget
     * @return array
     */
    public function getConfigureWidgetType(){
        if(! isset(self::$instance[__FUNCTION__])){
            $ret = array();
            $ret[] = '3';
            self::$instance[__FUNCTION__] = $ret;
        }
        return self::$instance[__FUNCTION__];
    }
    const UPGRADE_WF_FAILED_IS_NOT_MUTEX = '50';
    const UPGRADE_WF_FAILED_WIDGET_OLD_FOLDER_NOT_EXISTED = '60';
    const UPGRADE_WF_FAILED_DROP_DATABASE_TMWF_OLD = '70';
    const UPGRADE_WF_FAILED_CREATE_DATABASE_TMWF_OLD = '80';
    const UPGRADE_WF_FAILED_RENAME_TABLE_FROM_CURRENTDB_TO_OLDDB = '90';
    const UPGRADE_WF_FAILED_UNREGCONIZED_DB_TYPE = '100';
    const UPGRADE_WF_FAILED_EXEC_INTERFACE_INIT_WFDBSCHEMA = '110';
    const UPGRADE_WF_FAILED_EXEC_INTERFACE_SYN_WIDGETXML_TODB = '120';
    const UPGRADE_WF_FAILED_EXEC_INTERFACE_SYN_WIDGETCOMPONENTXML_TODB = '121';
    const UPGRADE_WF_FAILED_EXEC_INTERFACE_SYN_SERVERLISTTYPE = '130';
    const UPGRADE_WF_FAILED_MIGRATE_TABLE = '139';
    const UPGRADE_WF_FAILED_MIGRATE_TABLE_PROXYLIST = '140';
    const UPGRADE_WF_FAILED_MIGRATE_TABLE_SERVERLIST = '150';
    const UPGRADE_WF_FAILED_MIGRATE_TABLE_USERDATA = '160';
    const UPGRADE_WF_FAILED_MIGRATE_TABLE_USERS = '170';
    const UPGRADE_WF_FAILED_UPDATE_WPINFO_INI = '180';
    const UPGRADE_WF_FAILED_DROP_AND_RECREATE_TABLE_SERVERLISTTYPE = '190';
}